package com.zytool.easyrestful.core.convert;

import cn.hutool.core.util.StrUtil;

import javax.persistence.Column;
import java.lang.reflect.Field;

public class DefaultNamingConvertor implements NamingConvertor {
    @Override
    public Convertor getType() {
        return Convertor.DEFAULT;
    }

    @Override
    public String field2Column(Field field) {
        Column column = field.getAnnotation(Column.class);
        return column != null && !StrUtil.isBlank(column.name()) ? column.name() : field.getName();
    }

    @Override
    public String column2Field(String column) {
        return column;
    }
}
